package curator.dwj.cn;

import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.RetryUntilElapsed;

import java.util.List;

/**
 * Created by Administrator on 2017/11/14 0014.
 */
public class GetChildren {
    public static void main(String[] args) throws Exception {

        //RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
        //RetryPolicy retryPolicy = new RetryNTimes(5, 1000);
        RetryPolicy retryPolicy = new RetryUntilElapsed(5000, 1000);

        //CuratorFramework client = CuratorFrameworkFactory.newClient("192.168.110.134:2181", 5000, 5000, retryPolicy);
        CuratorFramework client = CuratorFrameworkFactory.builder()
                .connectString("192.168.110.134:2181")
                .sessionTimeoutMs(5000)
                .connectionTimeoutMs(5000)
                .retryPolicy(retryPolicy)
                .build();
        client.start();

        List<String> cList = client.getChildren()
                .forPath("dwj/1");
        System.out.println(client.toString());
        Thread.sleep(Integer.MAX_VALUE);
    }
}
